package org.tmad.ocms.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;

import org.tmad.ocms.log.LogFactory;
import org.tmad.ocms.model.Case;
import org.tmad.ocms.model.Volunteer;
import org.tmad.ocms.util.CommonUtils;


public class AdminDAO {
	private static Logger logger = LogFactory.getLogger();
	public boolean login(String email, String pwd) throws Exception{
		boolean result =false;
		
		Connection con =ConnectionManager.getDbConnection();
		Statement stmt =con.createStatement();
		ResultSet results =stmt.executeQuery("select * from volunteer where email_id='" + email + "' and password ='" + CommonUtils.getEncryptedPassword(pwd) +"'");
		//ResultSet results =stmt.executeQuery("select * from user where username='" + username + "'");
		while(results.next()){
			result = true;
		}
		return result;
	}

public static void main(String[] args) throws Exception {
	LoginDAO dao = new LoginDAO();
	boolean result =dao.login("harinath","secret");
	
	logger.info("user authentication status  " + result);
}
}
